import { getUser } from "@/lib/data";
import Image from "next/image";
import fetch from "node-fetch";
import React from "react";

const getData = async () => {
  const res = await fetch("https://jsonplaceholder.typicode.com/users/1", {
    cache: "no-store",
  });
  if (!res.ok) throw new Error("Something went wrong");
  return res.json();
};

const PostUser = async ({ post }) => {
  // const user = await getData();
  const user = await getUser(post.userId);

  return (
    <div>
      {user.img && <Image width={20} height={20} alt="post" src={user.img} />}
      <div>{user.username}</div>
      <div>{user.email}</div>
    </div>
  );
};

export default PostUser;
